// mystring.h: interface for the mystring class.
//
//////////////////////////////////////////////////////////////////////
#pragma once

#include <string.h>
#include <stdlib.h>
#include "base.h"

int BASE_API mystricmp(const char *s,const char *d);
class BASE_API mystring  
{
public:
	mystring();
	mystring(const char *pstr);
	mystring(const mystring &str);
	mystring(const char *pstr,int len);
	virtual ~mystring();
	const char *c_str()const{return m_pData;};
	friend mystring BASE_API operator+(const mystring &str,const mystring& rhs);
	friend mystring BASE_API operator+(const mystring &str,const char *pstr);
	friend mystring BASE_API operator+(const char *pstr,const mystring &str);
	
	char& operator[] (int i);
	mystring& operator+=(const mystring& rhs);
	mystring& operator+=(char ch);
	mystring& operator+=(const char *pstr);
	mystring& operator=(const mystring& rhs);
	mystring& operator=(const char *pstr);
	mystring& operator=(int n);
	mystring& operator=(long n);
	mystring& operator=(unsigned long n);
	mystring& operator=(float f);
	mystring& operator=(double f);

	mystring& operator+=(int n);
	mystring& operator+=(long n);
	mystring& operator+=(unsigned int n);
	mystring& operator+=(unsigned long n);
	mystring& operator+=(float f);
	mystring& operator+=(double f);
	mystring& operator<<(const mystring &str);
	mystring& operator<<(const char *pstr);
	mystring& operator<<(char c);
	mystring& operator<<(int n);
	mystring& operator<<(long l);
	mystring& operator<<(unsigned int n);
	mystring& operator<<(unsigned long l);
	mystring& operator<<(float f);
	mystring& operator<<(double f);
	
	bool operator==(const mystring& other) const;
	bool operator==(const char * other) const;
	bool operator!=(const mystring& other) const;
	bool operator!=(const char *pstr) const;
	bool operator>(const mystring &other)const;
	bool operator<(const mystring &other) const;

	int size()const{return m_nSize;};
	int length()const{return m_nLength;};
	void erase();
	bool empty()const{ return m_nLength == 0;};
	void toupper();
	void tolower();
	bool setstring(const char *pstr, int len);

	void trimleft();
	void trimright();
	int  find(char ch);
	int  find(const char *psubstr);
	void append(const char *pbuf,int len);
private:
	void defaultsize();
	void increasesize(int size);
private:
	int		m_nLength;
	int		m_nSize;
	char *	m_pData;
};
void TrimLeft(char *s);
void TrimRight(char *s);

